# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-mirage-time
_pkgname=mirage-time
pkgver=3.0.0
pkgrel=0
pkgdesc="Time operations for MirageOS"
url="https://github.com/mirage/mirage-time"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="ocaml-runtime ocaml-lwt ocaml-duration"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-lwt-dev ocaml-duration-dev"
makedepends="$depends_dev dune ocaml"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirage/mirage-time/releases/download/v$pkgver/mirage-time-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
066f9271c7871eb754cf9b3f8853f4861ce80d1cc31eb9a2384f3cd62441e15aa7636d19cc3bee6d56219fa5653b9f7da7d9b9d659fd1f7cd17326e7ba1715eb  ocaml-mirage-time-3.0.0.tar.bz2
"
